﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sheeps
{
    /// <summary>
    /// Basic object with position.
    /// </summary>
    public class ObjectWithPosition : IWithPosition, IWithOrientation
    {

        #region IWithPosition Members
        protected Vector3 position;

        /// <summary>
        /// Position of object.
        /// </summary>
        public virtual Vector3 Position
        {
            get
            {
                return this.position;
            }

            set
            {
                Vector3 translation = value - this.position; //new position - old position
                this.position = value;

                if (translation.Magnitude == 0)
                {
                    this.NormalizedOrientation = new Vector3(0, 0, 1);
                    return;
                }
                translation.Normalize();
                this.NormalizedOrientation = translation;
            }
        }

        #endregion

        #region IWithOrientation Members

        public Vector3 NormalizedOrientation
        {
            get;
            set;
        }

        #endregion

        /// <summary>
        /// Creates new instance of object with position
        /// </summary>
        public ObjectWithPosition()
        {
            this.Position = new Vector3(0, 0, 0);
        }




    }
}
